﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using IDAL;
using Models;

namespace DAL
{
    public class IntroductionInfoDAL:IIntroductionInfo
    {
        public const string SQL_GET_INTRODUCTION = @"select * from IntroductionInfo";
        public DataBase DB = new DataBase();

        public List<IntroductionInfo> GetIntroductionInfo()
        {
            List<IntroductionInfo> list = new List<IntroductionInfo>();
            DB.DatabaseConnection();
            SqlDataReader reader = DB.GetdataRecords(SQL_GET_INTRODUCTION);
            while (reader.Read())
            {
                IntroductionInfo introductioninfo = new IntroductionInfo();
                ReadtoIntroductionInfo(reader, introductioninfo);
                list.Add(introductioninfo);
            }
            DB.CloseDB();
            return list;
        }

        public void ReadtoIntroductionInfo(SqlDataReader reader, IntroductionInfo introductioninfo)
        {
            introductioninfo.IntroContent = reader["IntroContent"] is DBNull ? "" : reader["IntroContent"].ToString();
        }
        public int UpdateIntroductionInfo(IntroductionInfo introductioninfo)
        {
            int a = 1;
            return a;
        }
    }
}
